# Python中类
class ColorPrint:
    """彩色打印工具类"""
    # ANSI颜色代码
    RED = '\033[91m'
    GREEN = '\033[92m'
    YELLOW = '\033[93m'
    BLUE = '\033[94m'
    PURPLE = '\033[95m'
    CYAN = '\033[96m'
    WHITE = '\033[97m'
    RESET = '\033[0m'

    # 粗体
    BOLD = '\033[1m'
    # 下划线
    UNDERLINE = '\033[4m'

    stu =[
        ("张三", 20, 95),
        ("李四", 19, 82),
        ("王五", 21, 78),
        ("赵六", 20, 88),
    ]

    def __init__(self):
        print("类被实例化时，会自动调用__init__方法")


    @classmethod
    def red(cls,text):
        """打印红色文本"""
        print(f"{cls.RED}{text}{cls.RESET}")
        
    @classmethod
    def green(cls,text):
        """打印绿色文本"""
        print(f"{cls.GREEN}{text}{cls.RESET}")
        
    @classmethod
    def yellow(cls,text):
        """打印黄色文本"""
        print(f"{cls.YELLOW}{text}{cls.RESET}")
    
    @classmethod  #相当于类的静态方法，不需要实例化类就可以调用
    def blod(cls,text):
        """打印粗体文本"""
        print("{0}{1}{2}".format(cls.BOLD,text,cls.RESET))


    def print_stu(cls):
        """打印学生信息"""
        print(f"{'姓名':<10}{'年龄':<5}{'成绩':<5}",end="\n")
        for name, age, score in cls.stu:
            print(f"{name:<10}{age:<5}{score:<5}\n")

        
ColorPrint.red("这是红色文本")
ColorPrint.green("这是绿色文本")
ColorPrint.yellow("这是黄色文本")
ColorPrint.blod("这是粗体文本")


ColorPrint().print_stu()
